package com.ics.web.controller.travelstar.controller;

import com.ics.common.core.controller.BaseController;
import com.ics.common.core.domain.AjaxResult;
import com.ics.web.controller.travelstar.domain.TiresWarranty;
import com.ics.web.controller.travelstar.dto.TiresWarrantyDTO;
import com.ics.web.controller.travelstar.service.ITiresWarrantyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * @author shaoly
 * @description
 * @ClassName TiresWarrantyController.java
 * @createTime 2024年09月24日 14:30:55
 */
@RestController
@RequestMapping("/tires/warranty")
public class TiresWarrantyController extends BaseController {

    @Resource
    private ITiresWarrantyService warrantyService;

    /**
     * 保障政策列表
     */
    @ApiOperation("保障政策列表")
    @GetMapping("/list")
    public AjaxResult list(TiresWarrantyDTO warrantyDTO) {
        return success(warrantyService.listPage(warrantyDTO));
    }


    /**
     * 保障政策详情
     */
    @ApiOperation("保障政策详情")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(warrantyService.getById(id));
    }

    /**
     * 保障政策新增
     */
    @ApiOperation("保障政策新增")
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TiresWarranty warranty) {
        return toAjax(warrantyService.saveOrUpdate(warranty));
    }


    /**
     * 保障政策删除
     */
    @ApiOperation("保障政策删除")
    @PostMapping("/remove")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(warrantyService.removeByIds(Arrays.asList(ids.split(","))));
    }

}
